package statistics;

import java.util.Random;


public class ExponentialDistribution extends Distribution{

    protected double lambda;
    
    public ExponentialDistribution( double lambda  , Random random ){
        this.lambda = lambda;
        this.random = random;
    }
            

    public double expectation() {
       return 1/lambda;
    }


    public double variance() {
        return 1/(lambda*lambda);
    }


    public double nextRandom() {
        double U = random.nextDouble();
        return - 1/lambda * Math.log(U);
    }
    
    
}